/*
 * @Author: 李石
 * @Date: 2024-05-21 08:12:22
 * @LastEditors: lishi
 * @LastEditTime: 2024-07-18 17:21:52
 * @Description: 
 * Copyright (c) 2024 by ${lishi0105@163.com}, All Rights Reserved. 
 */
#ifndef _STREAM_PROXYER_HPP_
#define _STREAM_PROXYER_HPP_
#include <thread>
#include <stdint.h>
#include <BaseShared.hpp>

class StreamProxyer : public SharedBase<StreamProxyer>{
public:
    StreamProxyer(const std::string &app, const std::string &stream, const std::string &url, int32_t rtp_type);
    ~StreamProxyer();
    bool alive(){ return m_proxy_alive.load();}
    std::string playUrl(){ return m_play_url; }
    int codec_id(){ return m_codec_id.load(); }
private:
    void pushFrameThread();
    void monitorThread();
private:
    int32_t m_rtp_type;
    std::atomic<int> m_push_cnt;
    std::atomic<int> m_codec_id;
    std::atomic<bool> m_proxy_alive;
    std::atomic<bool> m_proxy_exit;
    std::string m_play_url;
    std::string m_src_url;
    std::string m_app_name;
    std::mutex  m_pusher_mtx;
    std::string m_stream_name;
    std::thread m_push_thread;
    std::thread m_monitor_thread;
public:
    static int m_server_port;
    static std::string m_local_ip;
};

#endif // _STREAM_PROXYER_HPP_